| FIGURE NO | DESCRIPTION | LINK |
|---|---|---|
| 6A | Hierarchical clustering based heatmap for all samples | link |
| 6B | PCA plot for all samples - grouped by PS group | link |
| 6C | PCA plot for all samples - grouped by Disease severity | link |
| S9 | Dendogram for all samples | link |
| S10 | PCA plots - per cluster bass (PS samples only) | link |
Import the Seurat object
skin_data.hm.sct <- readRDS(file="../ALL_SPATIAL_SAMPLES.RDS")
RE-NORMALIZING TO REGRESS OUT BATCH
skin_data.hm.sct_re_normalized <- SCTransform(skin_data.hm.sct,assay = "Spatial",new.assay.name ="SCT_BATCH_REGRESSED",vars.to.regress = c("sample.id"))
Calculating cell attributes from input UMI matrix: log_umi
Variance stabilizing transformation of count matrix of size 21901 by 16424
Model formula is y ~ log_umi
Get Negative Binomial regression parameters per gene
Using 2000 genes, 5000 cells
|
| | 0%
|
|=============================== | 25%
|
|============================================================== | 50%
|
|============================================================================================== | 75%
|
|=============================================================================================================================| 100%
Found 70 outliers - those will be ignored in fitting/regularization step
Second step: Get residuals using fitted parameters for 21901 genes
|
| | 0%
|
|=== | 2%
|
|====== | 5%
|
|========= | 7%
|
|=========== | 9%
|
|============== | 11%
|
|================= | 14%
|
|==================== | 16%
|
|======================= | 18%
|
|========================== | 20%
|
|============================ | 23%
|
|=============================== | 25%
|
|================================== | 27%
|
|===================================== | 30%
|
|======================================== | 32%
|
|=========================================== | 34%
|
|============================================= | 36%
|
|================================================ | 39%
|
|=================================================== | 41%
|
|====================================================== | 43%
|
|========================================================= | 45%
|
|============================================================ | 48%
|
|============================================================== | 50%
|
|================================================================= | 52%
|
|==================================================================== | 55%
|
|======================================================================= | 57%
|
|========================================================================== | 59%
|
|============================================================================= | 61%
|
|================================================================================ | 64%
|
|================================================================================== | 66%
|
|===================================================================================== | 68%
|
|======================================================================================== | 70%
|
|=========================================================================================== | 73%
|
|============================================================================================== | 75%
|
|================================================================================================= | 77%
|
|=================================================================================================== | 80%
|
|====================================================================================================== | 82%
|
|========================================================================================================= | 84%
|
|============================================================================================================ | 86%
|
|=============================================================================================================== | 89%
|
|================================================================================================================== | 91%
|
|==================================================================================================================== | 93%
|
|======================================================================================================================= | 95%
|
|========================================================================================================================== | 98%
|
|=============================================================================================================================| 100%
Computing corrected count matrix for 21901 genes
|
| | 0%
|
|=== | 2%
|
|====== | 5%
|
|========= | 7%
|
|=========== | 9%
|
|============== | 11%
|
|================= | 14%
|
|==================== | 16%
|
|======================= | 18%
|
|========================== | 20%
|
|============================ | 23%
|
|=============================== | 25%
|
|================================== | 27%
|
|===================================== | 30%
|
|======================================== | 32%
|
|=========================================== | 34%
|
|============================================= | 36%
|
|================================================ | 39%
|
|=================================================== | 41%
|
|====================================================== | 43%
|
|========================================================= | 45%
|
|============================================================ | 48%
|
|============================================================== | 50%
|
|================================================================= | 52%
|
|==================================================================== | 55%
|
|======================================================================= | 57%
|
|========================================================================== | 59%
|
|============================================================================= | 61%
|
|================================================================================ | 64%
|
|================================================================================== | 66%
|
|===================================================================================== | 68%
|
|======================================================================================== | 70%
|
|=========================================================================================== | 73%
|
|============================================================================================== | 75%
|
|================================================================================================= | 77%
|
|=================================================================================================== | 80%
|
|====================================================================================================== | 82%
|
|========================================================================================================= | 84%
|
|============================================================================================================ | 86%
|
|=============================================================================================================== | 89%
|
|================================================================================================================== | 91%
|
|==================================================================================================================== | 93%
|
|======================================================================================================================= | 95%
|
|========================================================================================================================== | 98%
|
|=============================================================================================================================| 100%
Calculating gene attributes
Wall clock passed: Time difference of 3.035921 mins
Determine variable features
Place corrected count matrix in counts slot
Regressing out sample.id
|
| | 0%
|
|= | 0%
|
|= | 1%
|
|== | 1%
|
|== | 2%
|
|=== | 2%
|
|=== | 3%
|
|==== | 3%
|
|==== | 4%
|
|===== | 4%
|
|====== | 4%
|
|====== | 5%
|
|======= | 5%
|
|======= | 6%
|
|======== | 6%
|
|======== | 7%
|
|========= | 7%
|
|========= | 8%
|
|========== | 8%
|
|=========== | 8%
|
|=========== | 9%
|
|============ | 9%
|
|============ | 10%
|
|============= | 10%
|
|============= | 11%
|
|============== | 11%
|
|============== | 12%
|
|=============== | 12%
|
|================ | 12%
|
|================ | 13%
|
|================= | 13%
|
|================= | 14%
|
|================== | 14%
|
|================== | 15%
|
|=================== | 15%
|
|=================== | 16%
|
|==================== | 16%
|
|===================== | 16%
|
|===================== | 17%
|
|====================== | 17%
|
|====================== | 18%
|
|======================= | 18%
|
|======================= | 19%
|
|======================== | 19%
|
|======================== | 20%
|
|========================= | 20%
|
|========================== | 20%
|
|========================== | 21%
|
|=========================== | 21%
|
|=========================== | 22%
|
|============================ | 22%
|
|============================ | 23%
|
|============================= | 23%
|
|============================= | 24%
|
|============================== | 24%
|
|=============================== | 24%
|
|=============================== | 25%
|
|================================ | 25%
|
|================================ | 26%
|
|================================= | 26%
|
|================================= | 27%
|
|================================== | 27%
|
|================================== | 28%
|
|=================================== | 28%
|
|==================================== | 28%
|
|==================================== | 29%
|
|===================================== | 29%
|
|===================================== | 30%
|
|====================================== | 30%
|
|====================================== | 31%
|
|======================================= | 31%
|
|======================================= | 32%
|
|======================================== | 32%
|
|========================================= | 32%
|
|========================================= | 33%
|
|========================================== | 33%
|
|========================================== | 34%
|
|=========================================== | 34%
|
|=========================================== | 35%
|
|============================================ | 35%
|
|============================================ | 36%
|
|============================================= | 36%
|
|============================================== | 36%
|
|============================================== | 37%
|
|=============================================== | 37%
|
|=============================================== | 38%
|
|================================================ | 38%
|
|================================================ | 39%
|
|================================================= | 39%
|
|================================================= | 40%
|
|================================================== | 40%
|
|=================================================== | 40%
|
|=================================================== | 41%
|
|==================================================== | 41%
|
|==================================================== | 42%
|
|===================================================== | 42%
|
|===================================================== | 43%
|
|====================================================== | 43%
|
|====================================================== | 44%
|
|======================================================= | 44%
|
|======================================================== | 44%
|
|======================================================== | 45%
|
|========================================================= | 45%
|
|========================================================= | 46%
|
|========================================================== | 46%
|
|========================================================== | 47%
|
|=========================================================== | 47%
|
|=========================================================== | 48%
|
|============================================================ | 48%
|
|============================================================= | 48%
|
|============================================================= | 49%
|
|============================================================== | 49%
|
|============================================================== | 50%
|
|=============================================================== | 50%
|
|=============================================================== | 51%
|
|================================================================ | 51%
|
|================================================================ | 52%
|
|================================================================= | 52%
|
|================================================================== | 52%
|
|================================================================== | 53%
|
|=================================================================== | 53%
|
|=================================================================== | 54%
|
|==================================================================== | 54%
|
|==================================================================== | 55%
|
|===================================================================== | 55%
|
|===================================================================== | 56%
|
|====================================================================== | 56%
|
|======================================================================= | 56%
|
|======================================================================= | 57%
|
|======================================================================== | 57%
|
|======================================================================== | 58%
|
|========================================================================= | 58%
|
|========================================================================= | 59%
|
|========================================================================== | 59%
|
|========================================================================== | 60%
|
|=========================================================================== | 60%
|
|============================================================================ | 60%
|
|============================================================================ | 61%
|
|============================================================================= | 61%
|
|============================================================================= | 62%
|
|============================================================================== | 62%
|
|============================================================================== | 63%
|
|=============================================================================== | 63%
|
|=============================================================================== | 64%
|
|================================================================================ | 64%
|
|================================================================================= | 64%
|
|================================================================================= | 65%
|
|================================================================================== | 65%
|
|================================================================================== | 66%
|
|=================================================================================== | 66%
|
|=================================================================================== | 67%
|
|==================================================================================== | 67%
|
|==================================================================================== | 68%
|
|===================================================================================== | 68%
|
|====================================================================================== | 68%
|
|====================================================================================== | 69%
|
|======================================================================================= | 69%
|
|======================================================================================= | 70%
|
|======================================================================================== | 70%
|
|======================================================================================== | 71%
|
|========================================================================================= | 71%
|
|========================================================================================= | 72%
|
|========================================================================================== | 72%
|
|=========================================================================================== | 72%
|
|=========================================================================================== | 73%
|
|============================================================================================ | 73%
|
|============================================================================================ | 74%
|
|============================================================================================= | 74%
|
|============================================================================================= | 75%
|
|============================================================================================== | 75%
|
|============================================================================================== | 76%
|
|=============================================================================================== | 76%
|
|================================================================================================ | 76%
|
|================================================================================================ | 77%
|
|================================================================================================= | 77%
|
|================================================================================================= | 78%
|
|================================================================================================== | 78%
|
|================================================================================================== | 79%
|
|=================================================================================================== | 79%
|
|=================================================================================================== | 80%
|
|==================================================================================================== | 80%
|
|===================================================================================================== | 80%
|
|===================================================================================================== | 81%
|
|====================================================================================================== | 81%
|
|====================================================================================================== | 82%
|
|======================================================================================================= | 82%
|
|======================================================================================================= | 83%
|
|======================================================================================================== | 83%
|
|======================================================================================================== | 84%
|
|========================================================================================================= | 84%
|
|========================================================================================================== | 84%
|
|========================================================================================================== | 85%
|
|=========================================================================================================== | 85%
|
|=========================================================================================================== | 86%
|
|============================================================================================================ | 86%
|
|============================================================================================================ | 87%
|
|============================================================================================================= | 87%
|
|============================================================================================================= | 88%
|
|============================================================================================================== | 88%
|
|=============================================================================================================== | 88%
|
|=============================================================================================================== | 89%
|
|================================================================================================================ | 89%
|
|================================================================================================================ | 90%
|
|================================================================================================================= | 90%
|
|================================================================================================================= | 91%
|
|================================================================================================================== | 91%
|
|================================================================================================================== | 92%
|
|=================================================================================================================== | 92%
|
|==================================================================================================================== | 92%
|
|==================================================================================================================== | 93%
|
|===================================================================================================================== | 93%
|
|===================================================================================================================== | 94%
|
|====================================================================================================================== | 94%
|
|====================================================================================================================== | 95%
|
|======================================================================================================================= | 95%
|
|======================================================================================================================= | 96%
|
|======================================================================================================================== | 96%
|
|========================================================================================================================= | 96%
|
|========================================================================================================================= | 97%
|
|========================================================================================================================== | 97%
|
|========================================================================================================================== | 98%
|
|=========================================================================================================================== | 98%
|
|=========================================================================================================================== | 99%
|
|============================================================================================================================ | 99%
|
|============================================================================================================================ | 100%
|
|=============================================================================================================================| 100%
Centering data matrix
|
| | 0%
|
|=============================== | 25%
|
|============================================================== | 50%
|
|============================================================================================== | 75%
|
|=============================================================================================================================| 100%
Warning: Keys should be one or more alphanumeric characters followed by an underscore, setting key from sct_batch_regressed_ to sctbatchregressed_Set default assay to SCT_BATCH_REGRESSED
IDENTIFY DE GENES - LESIONAL VS HEALTHY
LES_vs_HEALTHY_v1 <- FindMarkers(skin_data.hm.sct_re_normalized,group.by = "DISEASE_STATUS",ident.1 = "Lesional",ident.2 = "Healthy skin")
Error in FindMarkers(skin_data.hm.sct_re_normalized, group.by = "DISEASE_STATUS", :
object 'skin_data.hm.sct_re_normalized' not found
NON_LES_vs_HEALTHY <- FindMarkers(skin_data.hm.sct_re_normalized,group.by = "DISEASE_STATUS",ident.1 = "Non-Lesional",ident.2 = "Healthy skin")
LES_VS_NON_LES <- FindMarkers(skin_data.hm.sct_re_normalized,group.by = "DISEASE_STATUS",ident.1 = "Lesional",ident.2 = "Non-Lesional")
skin_data.hm.sct_re_normalized <- NormalizeData(skin_data.hm.sct_re_normalized,assay = "Spatial")
LES_vs_HEALTHY_v3 <- FindMarkers(skin_data.hm.sct_re_normalized,group.by = "DISEASE_STATUS",ident.1 = "Lesional",ident.2 = "Healthy skin",assay = "Spatial",test.use = "LR",latent.vars=c("Batch"))
NON_LES_vs_HEALTHY_v3 <- FindMarkers(skin_data.hm.sct_re_normalized,group.by = "DISEASE_STATUS",ident.1 = "Non-Lesional",ident.2 = "Healthy skin",assay = "Spatial",test.use = "LR",latent.vars=c("Batch"))
LES_VS_NON_LES_v3 <- FindMarkers(skin_data.hm.sct,group.by = "DISEASE_STATUS",ident.1 = "Lesional",ident.2 = "Non-Lesional",assay = "Spatial",test.use = "LR",latent.vars=c("Batch"))
LES_vs_HEALTHY_v4 <- FindMarkers(skin_data.hm.sct_re_normalized,group.by = "DISEASE_STATUS",ident.1 = "Lesional",ident.2 = "Healthy skin",assay = "Spatial",test.use = "wilcox")
NON_LES_vs_HEALTHY_v4 <- FindMarkers(skin_data.hm.sct_re_normalized,group.by = "DISEASE_STATUS",ident.1 = "Non-Lesional",ident.2 = "Healthy skin",assay = "Spatial",test.use = "wilcox")
LES_VS_NON_LES_v4 <- FindMarkers(skin_data.hm.sct,group.by = "DISEASE_STATUS",ident.1 = "Lesional",ident.2 = "Non-Lesional",assay = "Spatial",test.use = "wilcox")
LES_vs_HEALTHY_v3_filtered <- LES_vs_HEALTHY_v3 %>% filter(p_val_adj<=0.1)
NON_LES_vs_HEALTHY_v3_filtered <- NON_LES_vs_HEALTHY_v3 %>% filter(p_val_adj<=0.1)
LES_VS_NON_LES_v3_filtered <- LES_VS_NON_LES_v3 %>% filter(p_val_adj<=0.1)
LES_vs_HEALTHY_v4_filtered <- LES_vs_HEALTHY_v4 %>% filter(p_val_adj<=0.1)
NON_LES_vs_HEALTHY_v4_filtered <- NON_LES_vs_HEALTHY_v4 %>% filter(p_val_adj<=0.1)
LES_VS_NON_LES_v4_filtered <- LES_VS_NON_LES_v4 %>% filter(p_val_adj<=0.1)
write.csv(LES_vs_HEALTHY_v3_filtered,file="DE_RESULTS_LES_vs_HEALTHY_(LR_TEST).csv")
write.csv(NON_LES_vs_HEALTHY_v3_filtered,file="DE_RESULTS_NON_LES_vs_HEALTHY_(LR_TEST).csv")
write.csv(LES_VS_NON_LES_v3_filtered,file="DE_RESULTS_LES_VS_NON_LES_(LR_TEST).csv")
write.csv(LES_vs_HEALTHY_v4_filtered,file="DE_RESULTS_LES_vs_HEALTHY_(WILCOX_TEST).csv")
write.csv(NON_LES_vs_HEALTHY_v4_filtered,file="DE_RESULTS_NON_LES_vs_HEALTHY_(WILCOX_TEST).csv")
write.csv(LES_VS_NON_LES_v4_filtered,file="DE_RESULTS_LES_VS_NON_LES_(WILCOX_TEST).csv")
LES_vs_HEALTHY_v4 <- FindMarkers(skin_data.hm.sct_re_normalized,group.by = "DISEASE_STATUS",ident.1 = "Lesional",ident.2 = "Healthy skin",assay = "Spatial",test.use = "LR",latent.vars=c("sample.id"))
NON_LES_vs_HEALTHY_v4 <- FindMarkers(skin_data.hm.sct_re_normalized,group.by = "DISEASE_STATUS",ident.1 = "Non-Lesional",ident.2 = "Healthy skin",assay = "Spatial",test.use = "LR",latent.vars=c("sample.id"))
LES_VS_NON_LES_v4 <- FindMarkers(skin_data.hm.sct,group.by = "DISEASE_STATUS",ident.1 = "Lesional",ident.2 = "Non-Lesional",assay = "Spatial",test.use = "LR",latent.vars=c("sample.id"))
LES_vs_HEALTHY_v4_filtered <- LES_vs_HEALTHY_v4 %>% filter(p_val_adj<=0.1)
NON_LES_vs_HEALTHY_v4_filtered <- NON_LES_vs_HEALTHY_v4 %>% filter(p_val_adj<=0.1)
LES_VS_NON_LES_v4_filtered <- LES_VS_NON_LES_v4 %>% filter(p_val_adj<=0.1)
write.csv(LES_vs_HEALTHY_v4_filtered,file="DE_RESULTS_LES_vs_HEALTHY_(LR_TEST)(SAMPLE_VAR).csv")
write.csv(NON_LES_vs_HEALTHY_v4_filtered,file="DE_RESULTS_NON_LES_vs_HEALTHY_(LR_TEST)(SAMPLE_VAR).csv")
write.csv(LES_VS_NON_LES_v4_filtered,file="DE_RESULTS_LES_VS_NON_LES_(LR_TEST)(SAMPLE_VAR).csv")
Import Pseudo-counts from the Seurat object
pseudo.counts <- Seurat:::PseudobulkExpression(object = skin_data.hm.sct,assays = "Spatial",group.by = "sample.id",slot = "counts",pb.method = "aggregate")
summary(colSums(pseudo.counts$Spatial))
Min. 1st Qu. Median Mean 3rd Qu. Max.
211576 963567 1826699 2826222 4051790 10120020
colSums(pseudo.counts$Spatial>10)
HV1_S1_R1 HV1_S1_R2 HV2_S1_R1 HV2_S1_R2 HV2_S2 HV3_S1 HV3_S2 PSA_LES_P1 PSA_LES_P2_R1
9100 9105 10190 12563 7489 11816 10507 13152 10717
PSA_LES_P2_R2 PSA_LES_P3_R1 PSA_LES_P3_R2 PSA_LES_P4 PSA_LES_P5 PSA_NON_LES_P1 PSA_NON_LES_P2 PSA_NON_LES_P3 PSA_NON_LES_P4
13651 8690 13803 12429 12463 10040 8428 12828 11984
PSO_LES_P1 PSO_LES_P2_R1 PSO_LES_P2_R2 PSO_LES_P3 PSO_LES_P4 PSO_LES_P5 PSO_LES_P6 PSO_NON_LES_P1 PSO_NON_LES_P2
12697 8031 13411 10764 13216 12779 13118 7391 3140
PSO_NON_LES_P3 PSO_NON_LES_P4 PSO_NON_LES_P5
3910 10904 11626
pseudo.counts.df <- as.data.frame(pseudo.counts$Spatial) %>% rownames_to_column("Gene")
Genes <- pseudo.counts.df$Gene
library(DESeq2)
groups.table <- read.csv(file="PSEUDO-BULK-DATA/groups.table.csv",stringsAsFactors = TRUE) %>% filter(Sample.ID!="") %>% column_to_rownames("Sample.ID") %>% unite("DISEASE_and_SEVERITY","GROUP_I","SEVERITY", sep = "_", remove = FALSE, na.rm = FALSE)
coldata <- groups.table[,c("DISEASE_and_SEVERITY","GROUP_I","SEVERITY","BATCH")]
# Ordering the file
counts.file <- pseudo.counts.df[,rownames(groups.table)]
#counts.file <- mutate_all(counts.file, function(x) as.numeric(as.character(x)))
group.name <- colnames(groups.table)[1]
groups.levels <- factor(groups.table[,group.name]) %>% levels()
rownames(counts.file) <- Genes
counts.final <- counts.file
# Run DE here
dds <- DESeqDataSetFromMatrix(countData = counts.final,colData=groups.table,design = ~BATCH + GROUP_I)
dds <- DESeq(dds,quiet = TRUE)
normalized.counts <- counts(dds, normalized=TRUE)
colSums(normalized.counts)
HV1_S1_R1 HV2_S1_R1 HV3_S1 HV2_S2 HV1_S1_R2 HV2_S1_R2 HV3_S2 PSO_LES_P2_R1 PSO_NON_LES_P2 PSO_LES_P2_R2
1794826 1740896 1544520 1374940 1413584 1427695 1596350 1743215 1695625 1682631
PSA_LES_P5 PSA_LES_P2_R1 PSA_NON_LES_P2 PSA_LES_P2_R2 PSO_LES_P3 PSO_NON_LES_P3 PSA_LES_P4 PSA_NON_LES_P4 PSO_LES_P6 PSO_LES_P1
1879940 3007601 1637527 2111038 2014346 1871857 1663323 1505774 1818696 2911079
PSO_NON_LES_P1 PSA_LES_P3_R1 PSA_NON_LES_P3 PSA_LES_P3_R2 PSO_LES_P5 PSO_NON_LES_P5 PSA_LES_P1 PSA_NON_LES_P1 PSO_LES_P4 PSO_NON_LES_P4
1583144 1958126 1684964 2165046 2297236 1663951 2658807 1609042 1845900 1512737
vsd <- vst(dds, blind=TRUE)
PCA plots showing clustering of samples based on disease group and severity / PASI score.
plotPCA(vsd, intgroup=c("GROUP_I","GROUP_II"))+ scale_color_manual(values=c("dimgray","#cc3333","#ffcc33","#ff9999","#ff9933"))
pcaData <- plotPCA(vsd, intgroup=c("SEVERITY","PASI_SCORE","DISEASE_and_SEVERITY"), returnData=TRUE)
percentVar <- round(100 * attr(pcaData, "percentVar"))
#pdf("ALL_SAMPLES_PCA_PLOT.pdf",height = 8,width = 10)
ggplot(pcaData, aes(PC1, PC2, fill=PASI_SCORE, shape=DISEASE_and_SEVERITY)) +
geom_point(size=3) +
xlab(paste0("PC1: ",percentVar[1],"% variance")) +
ylab(paste0("PC2: ",percentVar[2],"% variance")) +
coord_fixed() +
scale_shape_manual(values=c(21,22,23,24,25))
#dev.off()
sampleDists <- dist(t(assay(vsd)))
library("RColorBrewer")
library("pheatmap")
sampleDistMatrix <- as.matrix(sampleDists)
rownames(sampleDistMatrix) <- paste(vsd$GROUP_I, vsd$SEVERITY,vsd$GROUP_II, sep="-")
colnames(sampleDistMatrix) <- NULL
colors <- colorRampPalette(brewer.pal(9, "RdYlBu")) (255)
#pdf("HC_WITH_HEATMAP.pdf",height = 15,width = 15)
print(pheatmap(sampleDistMatrix,
clustering_distance_rows=sampleDists,
clustering_distance_cols=sampleDists,
col=colors))
#dev.off()
hc <- hclust(sampleDists)
print(plot(hc, labels=paste(vsd$GROUP_I,vsd$SEVERITY,vsd$GROUP_II,sep = ":")))
NULL
vsd_subset <- vsd[,vsd$GROUP_I %in% c("Non-Lesional","Lesional")]
sampleDists <- dist(t(assay(vsd_subset)))
hc <- hclust(sampleDists)
#pdf("DENDOGRAM_PS_ONLY.pdf",height = 10,width = 10)
print(plot(hc, labels=paste(vsd_subset$GROUP_I,vsd_subset$SEVERITY,vsd_subset$PASI_SCORE,sep = ":")))
NULL
#dev.off()
## PCA PLOT
#pdf(file="PCA_PS_ONLY.pdf",height = 8,width = 10)
plotPCA(vsd_subset, intgroup=c("GROUP_I", "SEVERITY")) + geom_text(label = vsd_subset$PASI_SCORE,nudge_x = 2, nudge_y = 2) + scale_color_manual(values=c("#ff9999","#cc3333","#ffcc33","#ff9933"))
#dev.off()
## PCA PLOT
#pdf(file="PCA_ALL_SAMPLES.pdf",height = 8,width = 10)
plotPCA(vsd, intgroup=c("GROUP_I", "GROUP_II")) + geom_text(label = vsd$PASI_SCORE,nudge_x = 2, nudge_y = 2) + scale_color_manual(values=c("dimgray","#cc3333","#ffcc33","#ff9999","#ff9933"))
#dev.off()
sampleDists <- dist(t(assay(vsd)))
hc <- hclust(sampleDists)
#pdf("DENDOGRAM_ALL_SAMPLES.pdf",height = 10,width = 10)
print(plot(hc, labels=paste(vsd$GROUP_I,vsd$SEVERITY,vsd$GROUP_II,vsd$PASI_SCORE,sep = ":")))
NULL
#dev.off()
sampleDistMatrix <- as.matrix(sampleDists)
rownames(sampleDistMatrix) <- paste(vsd$GROUP_I, vsd$SEVERITY,vsd$GROUP_II,vsd$PASI_SCORE, sep="-")
colnames(sampleDistMatrix) <- NULL
colors <- colorRampPalette( rev(brewer.pal(9, "Blues")) )(255)
#pdf("HC_ALL_SAMPLES_HEATMAP.pdf",height = 15,width = 15)
print(pheatmap(sampleDistMatrix,
clustering_distance_rows=sampleDists,
clustering_distance_cols=sampleDists,
col=colors))
#dev.off()
res.1<- results(dds,contrast=c('GROUP_I','Lesional','Healthy Skin')) %>% as.data.frame() %>% rownames_to_column("Gene") %>% dplyr::filter(padj<0.1)
res.2<- results(dds,contrast=c('GROUP_I','Lesional','Non-Lesional')) %>% as.data.frame() %>% rownames_to_column("Gene") %>% dplyr::filter(padj<0.1)
res.3<- results(dds,contrast=c('GROUP_I','Non-Lesional','Healthy Skin')) %>% as.data.frame() %>% rownames_to_column("Gene") %>% dplyr::filter(padj<0.1)
res.1<- results(dds_2,contrast=c('GROUP_I','Lesional','Healthy Skin')) %>% as.data.frame() %>% rownames_to_column("Gene") %>% dplyr::filter(padj<0.1)
res.2<- results(dds_2,contrast=c('GROUP_I','Lesional','Non-Lesional')) %>% as.data.frame() %>% rownames_to_column("Gene") %>% dplyr::filter(padj<0.1)
res.3<- results(dds_2,contrast=c('GROUP_I','Non-Lesional','Healthy Skin')) %>% as.data.frame() %>% rownames_to_column("Gene") %>% dplyr::filter(padj<0.1)
dds$group <- factor(paste0(dds$GROUP_I, dds$SEVERITY))
design(dds) <- ~ group
dds <- DESeq(dds)
res.1_v2<- results(dds,contrast=c('group','LesionalModerate-severe','Healthy SkinHealthy')) %>% as.data.frame() %>% rownames_to_column("Gene") %>% dplyr::filter(padj<0.1)
res.2_v2<- results(dds,contrast=c('group','LesionalMild','Healthy SkinHealthy')) %>% as.data.frame() %>% rownames_to_column("Gene") %>% dplyr::filter(padj<0.1)
#res.2<- results(dds,contrast=c('GROUP_I','Lesional','Non-Lesional')) %>% as.data.frame() %>% rownames_to_column("Gene") %>% dplyr::filter(padj<0.1)
#res.3<- results(dds,contrast=c('GROUP_I','Non-Lesional','Healthy Skin')) %>% as.data.frame() %>% rownames_to_column("Gene") %>% dplyr::filter(padj<0.1)
Group.data <- table(skin_data.hm.sct@meta.data$DISEASE_STATUS,skin_data.hm.sct@meta.data$Spatial.regions) %>% as.data.frame()
colnames(Group.data) <- c("Group","Cluster","Frquency")
write.csv(Group.data,"CLUSTER_FREQUENCY_BY_GROUP.csv")
cluster.labels <- unique(skin_data.hm.sct@meta.data$Spatial.regions) %>% as.vector() %>% sort(decreasing = TRUE)
cluster.labels
[1] "9 Adipose" "8 Hair follicle and sebaceous glands" "7 Epidermis"
[4] "6 Mixed" "5 Connective tissue" "4 Epidermis"
[7] "3 Epidermis" "2 Eccrine + melanocyte precursors" "16 Adipose, fibroblasts"
[10] "15 Mixed" "14 Smooth muscle" "13 Immunoglobulins, fibroblasts"
[13] "12 Endothelial cells" "11 Smooth muscle" "10 Suprabasal keratinocytes"
[16] "1 Macs + fibroblasts" "0 Fibroblasts"
cluster.labels.filtered <- c("9 Adipose","10 Suprabasal keratinocytes","11 Smooth muscle","12 Endothelial cells","13 Immunoglobulins, fibroblasts","14 Smooth muscle","15 Mixed","16 Adipose, fibroblasts")
for(x in cluster.labels){
subset.data <- subset(skin_data.hm.sct,Spatial.regions %in% c(x))
dds <- pseudo_bulk_out(subset.data,group_label = "sample.id",groups_tbl_path = "PSEUDO-BULK-DATA/groups.table.csv")
if(!is.null(dds)){
tryCatch({
vsd <- vst(dds, blind=TRUE)
# ALL PSORIASIS SAMPLES
vsd_subset <- vsd[,vsd$GROUP_I %in% c("Lesional","Non-Lesional")]
## PCA PLOT
#pdf(file=paste("PSEUDO_BULK_OUTPUT/ALL_PS_SAMPLES/",x,"_PCA_PLOT_PSEUDOBULK_ALL_SAMPLES.pdf"),height = 8,width = 10)
print(plotPCA(vsd_subset, intgroup=c("GROUP_I", "SEVERITY"))+ ggtitle(paste("PCA Plot for -",x))+ scale_color_manual(values=c("#ff9999","#cc3333","#ffcc33","#ff9933")))
#dev.off()
}, error=function(e){ skip_to_next <<- TRUE})
}
}
#cluster.ids <- skin_data.hm.sct@meta.data$Spatial.regions %>% unique() %>% as.vector()
for(x in cluster.labels.filtered){
subset.data <- subset(skin_data.hm.sct,Spatial.regions %in% c(x))
dds <- pseudo_bulk_out(subset.data,group_label = "sample.id",groups_tbl_path = "PSEUDO-BULK-DATA/groups.table.csv")
if(!is.null(dds)){
tryCatch({
vsd <- vst(dds, blind=TRUE,nsub = 100)
normalized.counts <- counts(dds, normalized=TRUE)
# ONLY PSORIASIS SAMPLES
vsd_subset <- vsd[,vsd$GROUP_I %in% c("Lesional","Non-Lesional")]
## PCA PLOT
#pdf(file=paste("PSEUDO_BULK_OUTPUT/ALL_SAMPLES(VERSION_2)/",x,"_PCA_PLOT_PSEUDOBULK_ALL_SAMPLES.pdf"),height = 8,width = 10)
print(plotPCA(vsd_subset, intgroup=c("GROUP_I", "SEVERITY"))+ ggtitle(paste("PCA Plot for -",x)))
#dev.off()
}, error=function(e){ skip_to_next <<- TRUE})
}
}
subset.data <- subset(skin_data.hm.sct,Spatial.regions %in% c("1 Macs + fibroblasts"))
dds <- pseudo_bulk_out(subset.data,group_label = "sample.id",groups_tbl_path = "PSEUDO-BULK-DATA/groups.table.csv")
vsd <- vst(dds, blind=TRUE,nsub = 100)
# ALL PSORIASIS SAMPLES
vsd_subset_2 <- vsd[,vsd$GROUP_I %in% c("Lesional","Non-Lesional")]
#pdf(file=paste("PSEUDO_BULK_OUTPUT/ALL_PS_SAMPLES/","1 Macs + fibroblasts","_PCA_PLOT_PSEUDOBULK_ALL_SAMPLES(WITH_LABELS)(V2).pdf"),height = 8,width = 10)
plotPCA(vsd_subset_2, intgroup=c("GROUP_I", "SEVERITY")) + geom_text(label = vsd_subset_2$PASI_SCORE,nudge_x = 0.50, nudge_y = 1) + scale_color_manual(values=c("#ff9999","#cc3333","#ffcc33","#ff9933"))
#dev.off()
#12 Endothelial cells
subset.data <- subset(skin_data.hm.sct,Spatial.regions %in% c("12 Endothelial cells"))
dds <- pseudo_bulk_out(subset.data,group_label = "sample.id",groups_tbl_path = "PSEUDO-BULK-DATA/groups.table.csv")
vsd <- vst(dds, blind=TRUE,nsub = 100)
# ALL PSORIASIS SAMPLES
vsd_subset_2 <- vsd[,vsd$GROUP_I %in% c("Lesional","Non-Lesional")]
#pdf(file=paste("PSEUDO_BULK_OUTPUT/ALL_PS_SAMPLES/","12 Endothelial cells","_PCA_PLOT_PSEUDOBULK_ALL_SAMPLES(WITH_LABELS)(V2).pdf"),height = 8,width = 10)
plotPCA(vsd_subset_2, intgroup=c("GROUP_I", "SEVERITY")) + geom_text(label = vsd_subset_2$PASI_SCORE,nudge_x = 0.50, nudge_y = 1) + scale_color_manual(values=c("#ff9999","#cc3333","#ffcc33","#ff9933"))
#dev.off()